﻿//  Copyright (c) 2011 Ray Liang (http://www.dotnetage.com)
//  Licensed MIT: http://www.opensource.org/licenses/mit-license.php

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DNA.Mvc.Notification
{
    public abstract class SubscriptionSenderBase:ISubscriptionSender
    {
        public virtual string Filter { get; set; }

        public abstract void Send(string[] subscribers, IMessage message);

        void ISubscriptionSender.Send(string[] subscribers, IMessage message)
        {
            //Enable filter
            if (!string.IsNullOrEmpty(Filter))
            {
                if (!message.TypeName.Equals(Filter, StringComparison.OrdinalIgnoreCase))
                    return;
            }
            this.Send(subscribers, message);
        }

        string ISubscriptionSender.Filter
        {
            get { return this.Filter; }
        }
    }
}
